//
//  DeleteCombinationsTopView.swift
//  MyCloset
//
//  Created by 牟好好 on 2024/11/19.
//

import SwiftUI

struct DeleteCombinationsTopView: View {
    @Binding var isShowTrash: Bool
    @State private var showAlert: Bool = false
    var reset: () -> Void
    
    var body: some View {
        HStack {
            Button(action: { showAlert = true }, label: {
                Text("重置搭配")
                    .padding(.horizontal)
                    .padding(.vertical, 10)
                    .background(.red)
                    .cornerRadius(8)
            })
            
            Spacer()
            
            Button(action: { isShowTrash.toggle() }, label: {
                Text(isShowTrash ? "退出管理" : "管理")
                    .padding(.horizontal)
                    .padding(.vertical, 10)
                    .background(.green)
                    .cornerRadius(8)
            })
        }
        .padding(.horizontal, boundsWidth * 0.05)
        .foregroundStyle(.white)
        .alert(isPresented: $showAlert, content: {
            Alert(
                title: Text("重置搭配"),
                message: Text("你确定要重置为系统默认搭配吗？"),
                primaryButton: .default(Text("确认")) {
                    reset()
                },
                secondaryButton: .cancel()
            )
        })
    }
}

#Preview {
    DeleteCombinationsTopView(isShowTrash: .constant(true)) {}
}
